package com.query;

import org.apache.commons.lang3.StringUtils;

public class NoticeQuery extends BaseQuery {

    private String searchKey;
    private String searchValue;
    private Integer type;

    @Override
    protected void init() {
        if (StringUtils.isNotBlank(searchValue)) {
            if ("0".equals(searchKey)) {
                params.put("title:" + LINK.LIKE, "%" + StringUtils.trim(searchValue) + "%");
            } else if ("1".equals(searchKey)) {
                params.put("content:" + LINK.LIKE, "%" + StringUtils.trim(searchValue) + "%");
            }
        }
        if (null != type) {
            params.put("type:" + LINK.EQ, type);
        }
    }

    @Override
    public String sortOrder() {
        return "created DESC";
    }

    public String getSearchKey() {
        return searchKey;
    }

    public void setSearchKey(String searchKey) {
        this.searchKey = searchKey;
    }

    public String getSearchValue() {
        return searchValue;
    }

    public void setSearchValue(String searchValue) {
        this.searchValue = searchValue;
    }

    public Integer getType() {
        return type;
    }

    public void setType(Integer type) {
        this.type = type;
    }
}
